package com.syni.mdd.yhd.common.all.dao.jpa;

import com.syni.mdd.yhd.common.all.dao.BaseJPADao;
import com.syni.mdd.yhd.common.all.entity.BmsBusiness;
import com.syni.mdd.yhd.common.all.entity.BmsUserVideo;
import org.springframework.data.jpa.repository.Query;

import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Set;

public interface BmsUserVideoDao extends BaseJPADao<BmsUserVideo,Integer> {
    List<BmsUserVideo> findByBmsVideoIdIn(Collection ids);

    List<BmsUserVideo> findByUserId(Integer userId);

    BmsUserVideo findByBmsVideoId(Integer videoId);

    @Query(value = "select count(buv.id) num,buv.user_id from bms_user_video buv left join bms_video bv on " +
            "buv.bms_video_id = bv.id where buv.user_id = ?1 and bv.from_origin in(?2) and bv.is_delete = 0",nativeQuery = true)
    Map<String,Object> selfFindUserVideo(Integer userId,Set videoType);

}
